package cn.edu.sjtu.se.dslab.dao.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import cn.edu.sjtu.se.dslab.component.data.EquipmentCategory;
import cn.edu.sjtu.se.dslab.component.data.EquipmentProperty;
import cn.edu.sjtu.se.dslab.dao.IBaseDao;
import cn.edu.sjtu.se.dslab.dao.IEquipmentPropertyDao;

/**
 * 
 * @author longshaohang
 * 
 */
@Repository("equipmentPropertyDao")
public class EquipmentPropertyDaoImpl implements IEquipmentPropertyDao {

	@Resource(name = "baseDao")
	private IBaseDao<EquipmentProperty> baseDao;

	@Override
	public void save(EquipmentProperty property) {
		baseDao.save(property);
	}

	@Override
	public void update(EquipmentProperty property) {
		baseDao.update(property);
	}

	@Override
	public EquipmentProperty queryById(long id) {
		return baseDao.queryById(EquipmentProperty.class, id);
	}

	@Override
	public List<EquipmentProperty> queryByEquipmentCategory(
			EquipmentCategory category) {
		// TODO Auto-generated method stub
		StringBuffer hql = new StringBuffer();
		// 拼接sql语句
		hql.append("from EquipmentProperty a where ");
		hql.append(" a.category.id=");
		hql.append("" + category.getId());
		return baseDao.query(hql.toString());
	}

}
